/*******************************************************************************

This code file runs all the cleaning files in the proper order.

*******************************************************************************/

*** Manage settings

	run "~/Dropbox (MIT)/Research/NYC421a/code/modules/settings.do"
	
/*******************************************************************************
* Cleaning code for main dataset
*******************************************************************************/

	* Clean intersection of 2002 and 2019 NYC zoning maps
	do "$code/clean/pluto0219.do"

	* Get crosswalk from Building Identification Numbers (BINs) to borough-block-lot (BBL) codes
	* XXX need to document raw/match_fails.dta XXX
	do "$code/clean/xwalk/bin_to_bbl.do"
	
	* Get crosswalk from condo billing BBLs to tax-lot BBLs
	do "$code/clean/xwalk/condo_bbl_to_tax_bbl.do"

	* Get crosswalk from 2010 Census tracts to Neighborhood Tabulation Areas (NTAs)
	do "$code/clean/xwalk/ct_to_nta.do"

	* Get Census area characteristics
	do "$code/clean/census_area_characteristics.do"
	
	* Get Geographic Exclusion Area (GEA) borough-block-lot (BBL) codes for expansion area
	do "$code/clean/gea.do"
			
	* Clean 421-a receipt status from scraped assessment records
	do "$code/clean/status_421a_assessment_records.do"
	
	* Clean Department of Buildings (DOB) permit data
	do "$code/clean/permits.do"
	
	* Clean GEA BBLs
	do "$code/clean/gea.do"
	
	* Clean PLUTO -- main land use dataset
	do "$code/clean/pluto.do"
	
	* Clean assessment roll -- for use in measuring underassessment over time
	do "$code/clean/clean_assessment_roll.do"
	
	* Clean transaction data -- for use in measuring underassessment over time
	do "$code/clean/transactions.do"
	
	* Determine underassessment ratios
	do "$code/clean/underassessment.do"
	
	* Export coordinates for IHP / NPP / Liberty Zone mapping
	do "$code/clean/export_coordinates.do"

	* Note: The following code files are to be run in R at this step.
	* map_ihp.R --> produces ihp_status.csv (mapping of building coordinates to Inclusionary Housing Program [IHP] status)
	* map_npp.R --> produces npp_status.csv (mapping of building coordinates to Neighborhood Preservation Program [NPP] status)
	
	* Compile data
	do "$code/clean/compile_final.do"
		
/*******************************************************************************
* Cleaning code for additional datasets
*******************************************************************************/
	
	* Produce simulated instruments
	do "$code/clean/simulated_instruments.do"
	
	* Clean other housing assistance (Section 8, LIHTC, NYCHA) data
	do "$code/clean/other_housing_assistance.do"
	
	* Clean Opportunity Insights (OI) tract data
	do "$code/clean/oi_tract_data.do"
	
	* Cleans ACS data on housing costs for use in WTP component of MVPF calculations
	do "$code/clean/housing_costs.do"
